package com.xuzhiguang.baidu.pan.sdk.model;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

/**
 * @author xuzhiguang
 * @date 2020/6/26 13:01
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
@JsonIgnoreProperties(ignoreUnknown = true)
public class BaiduPanCommonResult {

    /**
     * 错误码 0 成功
     */
    @JsonAlias("error_code")
    private Integer errno;

    /**
     * 错误信息
     */
    @JsonAlias("error_msg")
    private String errmsg;

    /**
     * 请求id
     */
    private String requestId;

    public boolean isSuccess() {

        return this.errno == null || this.errno == 0;
    }

    @Override
    public String toString() {
        return "BaiduPanCommonResult{" +
                "errno=" + errno +
                ", errmsg='" + errmsg + '\'' +
                ", requestId='" + requestId + '\'' +
                '}';
    }

    public Integer getErrno() {
        return errno;
    }

    public void setErrno(Integer errno) {
        this.errno = errno;
    }

    public String getErrmsg() {
        return errmsg;
    }

    public void setErrmsg(String errmsg) {
        this.errmsg = errmsg;
    }

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }
}
